package vista;
import controlador.*;

public class VistaComercio extends javax.swing.JFrame {
	
	private static final long serialVersionUID = 1L;
    
    private javax.swing.JButton botonComprar;
    private javax.swing.JButton botonVolver;
    private javax.swing.JLabel etiquetaDinero;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JList listaPartesComprar;
    
    public VistaComercio(ControladorVistaComercio controlador) {
        initComponents();
        this.setLocationRelativeTo(null);  
        this.VistaComercioVisibilidadTrue();
        botonComprar.addActionListener(controlador.getListenerBotonComprar());
		botonVolver.addActionListener(controlador.getListenerBotonVolver());
    }
    
    public void VistaComercioVisibilidadTrue (){
		this.setVisible(true);  
	}
	
	public void VistaComercioVisibilidadFalse (){
		this.setVisible(false);  
	}
	
    public void SetEtiquetaDinero(String valor){
    	etiquetaDinero.setText(valor);
    }
  
    public void llenarListaPartesComprar (javax.swing.DefaultListModel jModel){
    	listaPartesComprar.setModel(jModel);
    }
    
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        etiquetaDinero = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        listaPartesComprar = new javax.swing.JList();
        jLabel4 = new javax.swing.JLabel();
        botonComprar = new javax.swing.JButton();
        botonVolver = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jLabel1.setFont(new java.awt.Font("Century Gothic", 0, 18));
        jLabel1.setText("COMERCIO");

        jLabel2.setFont(new java.awt.Font("Century Gothic", 0, 14));
        jLabel2.setText("DINERO:");

        etiquetaDinero.setFont(new java.awt.Font("Century Gothic", 0, 14));

        jScrollPane2.setViewportView(listaPartesComprar);

        jLabel4.setText("PARTES");

        botonComprar.setText("COMPRAR");

        botonVolver.setText("VOLVER ");
        setTitle("Car Tunning Experience 2008");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(jLabel1)
                                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 118, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(jLabel4)
                                .addComponent(etiquetaDinero, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(24, 24, 24)
                        .addComponent(botonComprar)
                        .addGap(33, 33, 33)
                        .addComponent(botonVolver, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(80, 80, 80))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(11, 11, 11)
                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(etiquetaDinero, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(15, 15, 15)
                .addComponent(jLabel4)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 197, Short.MAX_VALUE)
                .addGap(23, 23, 23)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(botonComprar)
                    .addComponent(botonVolver))
                .addContainerGap())
        );

        pack();
    }

   
   public int DevolverIndicePartesComprar() {
	   return listaPartesComprar.getSelectedIndex();
   }

   

    

    
}